postgres:
	docker run --name postgres1 -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=root -d -p 5432:5432 postgres
createDB:
	docker exec -it postgres1 createdb --username=root --owner=root cybertwin
dropDB:
	docker exec -it postgres1 dropdb cybertwin
redis:
	docker run -d --name redis1 -p 6400:6379 redis
gen-proto:
	protoc --proto_path=proto --go-grpc_out=. --go_out=. proto/*.proto
clean-proto:
	rm -r pb/*
migrateup:
	 migrate -path db/migration -database "postgresql://root:secret@localhost:5432/cybertwin?sslmode=disable" -verbose up
migratedown:
	 migrate -path db/migration -database "postgresql://root:secret@localhost:5432/cybertwin?sslmode=disable" -verbose down
run-test:
	go test -v -cover ./test/...
run-registry:
	go run access/registry/main/registry_center.go
run-registry-test:
	go test -v test/registry_test.go
run-ap:
	go run access/ap/main/ap_server.go
run-ct:
	go run cybertwin/main/cybertwin.go
# 使用方法make run-ue直接运行传统模式；make run-ue mode=fail则运行另一种断线重连模式
run-ue:
	@if [ -n "$(mode)" ]; then \
		go run ue/main/ue.go -mode=${mode}; \
	else \
  		go run ue/main/ue.go; \
  	fi
run-mue:
	go run ue/multi_ue/mue.go
run-echo:
	go run cloudserver/echoserver/main.go

# 如果需要增加sql语句功能，请在db/query中进行增加，然后make sqlc进行更新
sqlc:
	sqlc generate # 相关的配置在sqlc.yaml中

.PHONY: migrateup migratedown sqlc run-registry run-registry-test
